package com.hub.db.api;

import com.hub.db.entity.User;
import com.hub.db.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @ author 令狐冲
 * @ date & time 2025/2/21 16:20
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserApi {

    private final UserService userService;

    @PostMapping("/create")
    public String createUser(@RequestBody User user) {
        userService.createUser(user.getUserId(), user.getUserName());
        return "User created";
    }

    @GetMapping("/getById")
    public User getUser(@RequestParam("userId") Long userId) {
        return userService.getUserById(userId);
    }
}
